<template>
  <div class="home">
    <HomeMain />
  </div>
</template>
<script setup>
  import HomeNav from '@/views/home/components/HomeNav.vue';
  import HomeMain from '@/views/home/components/HomeMain.vue';
  import { onBeforeUnmount, onBeforeMount } from 'vue';
  const beforeUnloadHandler = (event) => {
    // 可以在这里执行一些逻辑，例如保存状态或数据
    console.log('页面即将刷新或关闭');
  };

  onBeforeMount(() => {
    // 注册 beforeunload 事件监听器
    window.addEventListener('beforeunload', beforeUnloadHandler);
  });

  onBeforeUnmount(() => {
    // 卸载组件前移除事件监听器
    window.removeEventListener('beforeunload', beforeUnloadHandler);
  });
</script>

<style lang="scss" scoped>
  .home {
    width: 100%;
    height: 100vh;
    overflow: hidden;
  }
</style>
